using UnityEngine;
using TMPro;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
using System.ComponentModel;
using StarterAssets;
public class BeginPanel : BasePanel
{
    public Button btnStart;
    public Button btnSetting;
    public Button btnEnd;
    public override void Awake()
    {
        Init();
    }
    public override void Init()
    {
        btnStart.onClick.AddListener(() =>
             StartGame()
        );
        btnSetting.onClick.AddListener(() =>
        {
            Setting();
        }

        );
        btnEnd.onClick.AddListener(() =>
        {
            Application.Quit();

        });
    }
    void Start()
    {
        if (!UIMgr.Instance.dicUI.ContainsKey("BeginPanel"))
            UIMgr.Instance.dicUI.Add("BeginPanel", this);


        EventCenter.Instance.AddEventListener(E_EventType.BeginScene_btn_exitSetting, ExitSetting);

    }
    public void StartGame()
    {
        //切换场景
        SceneManager.LoadSceneAsync(1);
        UIMgr.Instance.DestroyDic();
        EventCenter.Instance.RemoveEventListener(E_EventType.BeginScene_btn_exitSetting, ExitSetting);
        StarterAssetsInputs.HideCursor();
        GameMgr.Instance.gameMode = GameMgr.GameMode.Game;
    }
    public void Setting()
    {
        UIMgr.Instance.HidePanel<BeginPanel>();
        UIMgr.Instance.ShowPanel<SettingPanel>();

    }
     public void ExitSetting()
    {
        UIMgr.Instance.ShowPanel<BeginPanel>();
        UIMgr.Instance.HidePanel<SettingPanel>();

    }
}
